package com.wxzz.elearing.course.api.admin;


import com.alibaba.fastjson.JSONObject;
import com.wxzz.elearing.course.dto.*;
import com.wxzz.elearing.course.entity.*;
import com.wxzz.elearing.course.service.ICurriculumSectionTopicService;
import com.wxzz.elearing.course.service.ICurriculumService;
import com.wxzz.elearing.course.service.IWxUserCurriculumService;
import com.wxzz.elearing.course.vo.*;
import com.wxzz.elearning.common.dto.FeignEnterpriseDto;
import com.wxzz.elearning.common.dto.FeignWxUserDto;
import com.wxzz.elearning.common.exception.ServiceException;
import com.wxzz.elearning.common.vo.JgPageVo;
import com.wxzz.elearning.common.vo.ReturnVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 课程 前端控制器
 * </p>
 *
 * @author
 * @since 2021-03-10
 */
@RestController
@RequestMapping("/curriculum")
@Api(tags = "课程接口(后台)")
public class CurriculumController {

    @Autowired
    private ICurriculumService curriculumService;

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @ApiOperation(value = "总后台展示平台课程接口列表(后台)", notes = "课程接口列表(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategory", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategory(HttpServletResponse response, @RequestBody CurriculumDto curriculumDto) {
        curriculumDto.setCurriculumType(0);
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, 0);
    }

    @ApiOperation(value = "总后台展示企业课程接口列表(后台)", notes = "课程接口列表(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategory4Apply", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategory4Apply(HttpServletResponse response, @RequestBody CurriculumDto curriculumDto) {
        curriculumDto.setCurriculumType(1);
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, 1);
    }

    @ApiOperation(value = "查询该讲师的所有课程(后台)", notes = "查询该讲师的所有课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategory4docent", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategory4docent(HttpServletResponse response, @RequestBody CurriculumDto curriculumDto) {
        if (curriculumDto.getDocentId() == null) {
            throw new ServiceException("请传入讲师id");
        }
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, null);
    }


    @ApiOperation(value = "讲师培训课程接口列表(后台)", notes = "讲师培训课程接口列表(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategory4teacherTrain", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategory4teacherTrain(HttpServletResponse response,@RequestHeader String token,  @RequestBody CurriculumDto curriculumDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        curriculumDto.setEnterpriseId(jsonObject.getLong("enterpriseId"));
        curriculumDto.setCurriculumType(2);
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, null);
    }

    @ApiOperation(value = "培训课程接口列表(后台)", notes = "培训课程接口列表(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategory4train", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategory4train(HttpServletResponse response,@RequestHeader String token,  @RequestBody CurriculumDto curriculumDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        curriculumDto.setEnterpriseId(jsonObject.getLong("enterpriseId"));
        curriculumDto.setCurriculumType(3);
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, null);
    }

    @ApiOperation(value = "总后台企业上架申请课程接口列表(总后台)", notes = "总后台企业上架申请课程接口列表(总后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategory4enterprise", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategory4enterprise(HttpServletResponse response, @RequestBody CurriculumDto curriculumDto) {
        curriculumDto.setCurriculumType(0);
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, 1);
    }

    @ApiOperation(value = "总后台讲师上架申请课程接口列表(总后台)", notes = "总后台讲师上架申请课程接口列表(总后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategory4platform", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategory4platform(HttpServletResponse response, @RequestBody CurriculumDto curriculumDto) {
        curriculumDto.setCurriculumType(0);
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, 1);
    }

    @ApiOperation(value = "企业内部课程列表接口(后台)", notes = "企业内部课程列表接口(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategoryApply4enterprise", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategoryApply4enterprise(HttpServletResponse response, @RequestHeader String token, @RequestBody CurriculumDto curriculumDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        curriculumDto.setEnterpriseId(jsonObject.getLong("enterpriseId"));
        curriculumDto.setCurriculumType(0);
        curriculumDto.setIsApply(1);
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, 0);
    }

    @ApiOperation(value = "企业展示上架至平台的课程(后台)", notes = "企业展示上架至平台的课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategory4enterpriseId", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategory4enterpriseId(HttpServletResponse response, @RequestHeader String token, @RequestBody CurriculumDto curriculumDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        curriculumDto.setEnterpriseId(jsonObject.getLong("enterpriseId"));
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, 0);
    }


    @ApiOperation(value = "企业内部课程列表接口(企业详情)(后台)", notes = "企业内部课程列表接口(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumByCategory4enterpriseDetail", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listCurriculumByCategory4enterpriseDetail(HttpServletResponse response, @RequestHeader String token, @RequestBody CurriculumDto curriculumDto) {
        return curriculumService.listCurriculumByCategory(response, 0, curriculumDto, 0);
    }

    @ApiOperation(value = "查询课程详情(后台)", notes = "查询课程详情(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectCurriculumDetail/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO<CurriculumVo> selectCurriculumDetail(@RequestHeader String token, @ApiParam("课程id") @PathVariable Long curriculumId) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return curriculumService.selectCurriculumDetail(jsonObject.getLong("enterpriseId"), curriculumId);
    }

    @ApiOperation(value = "查询课程章节列表(后台)", notes = "查询课程章节列表(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumSection/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO<List<CurriculumUnit>> listCurriculumSection(@ApiParam("课程id") @PathVariable Long curriculumId) {
        return curriculumService.listCurriculumSection(null, curriculumId);
    }

    @ApiOperation(value = "查询课程章节测评列表(后台)", notes = "查询课程章节测评列表(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumSectionTopic/{curriculumSectionId}", method = RequestMethod.POST)
    public ReturnVO<List<CurriculumSectionTopic>> listCurriculumSectionTopic(@ApiParam("课程章节id") @PathVariable Long curriculumSectionId) {
        return curriculumService.listCurriculumSectionTopic(curriculumSectionId, 0);
    }

    @ApiOperation(value = "根据课程id查询人员学习情况(后台)", notes = "根据课程id查询人员学习情况(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectWxUserByCurriculum", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<WxUserCurriculum>>> selectWxUserByCurriculum(@Valid @RequestBody WxUserByCurriculumDto wxUserByCurriculumDto) {
        return curriculumService.selectWxUserByCurriculum(wxUserByCurriculumDto);
    }

    @ApiOperation(value = "根据课程id查询企业的学习情况(后台)", notes = "根据课程id查询企业的学习情况(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectEnterpriseByCurriculum", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<FeignEnterpriseDto>>> selectEnterpriseByCurriculum(@Valid @RequestBody WxUserByCurriculumDto wxUserByCurriculumDto) {
        return curriculumService.selectEnterpriseByCurriculum(wxUserByCurriculumDto);
    }

    @ApiOperation(value = "根据课程id查询人员学习情况数据统计(后台)", notes = "根据课程id查询人员学习情况数据统计(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectWxUserCurriculumStatisticsVoByCurriculum/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO<WxUserCurriculumStatisticsVo> selectWxUserCurriculumStatisticsVoByCurriculum(@PathVariable Long curriculumId) {
        return curriculumService.selectWxUserCurriculumStatisticsVoByCurriculum(curriculumId);
    }

    @ApiOperation(value = "根据课程id查询企业学习情况数据统计(后台)", notes = "根据课程id和企业id查询人员学习情况数据统计(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectEnterpriseCurriculumStatisticsVoByCurriculum/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO<WxUserCurriculumStatisticsVo> selectEnterpriseCurriculumStatisticsVoByCurriculum(@PathVariable Long curriculumId) {
        return curriculumService.selectEnterpriseCurriculumStatisticsVoByCurriculum(curriculumId);
    }

    @ApiOperation(value = "查询个人学习情况详情(后台)", notes = "查询个人学习情况详情(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectWxUserCurriculumVoByWxUserId/{wxUserId}/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO<WxUserCurriculumVo> selectWxUserCurriculumVoByWxUserId(@PathVariable Long wxUserId, @PathVariable Long curriculumId) {
        return curriculumService.selectWxUserCurriculumVoByWxUserId(wxUserId, curriculumId);
    }

    @ApiOperation(value = "查询企业学习情况详情(后台)", notes = "查询企业学习情况详情(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectEnterpriseCurriculumVoByCurriculum/{enterpriseId}/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO<EnterpriseCurriculumVo> selectEnterpriseCurriculumVoByCurriculum(@PathVariable Long enterpriseId, @PathVariable Long curriculumId) {
        return curriculumService.selectEnterpriseCurriculumVoByCurriculum(enterpriseId, curriculumId);
    }

    @ApiOperation(value = "查询课程学习情况详情(后台)", notes = "查询课程学习情况详情(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectCurriculumVoByCurriculum/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO<EnterpriseCurriculumVo> selectCurriculumVoByCurriculum(@PathVariable Long curriculumId) {
        return curriculumService.selectCurriculumVoByCurriculum(curriculumId);
    }

    @ApiOperation(value = "添加课程(平台课程)(后台)", notes = "添加课程/企业申请平台课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "savePlatformCurriculum", method = RequestMethod.POST)
    public ReturnVO savePlatformCurriculum(@RequestHeader String token, @RequestBody Curriculum curriculum) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        curriculum.setEnterpriseId(jsonObject.getLong("enterpriseId"));
        curriculum.setCurriculumType(0);
        curriculum.setIsDocentSend(jsonObject.getInteger("isDocent"));
        return curriculumService.saveCurriculum(jsonObject.getLong("id"), curriculum);
    }


    @ApiOperation(value = "添加课程(企业内部课程)(后台)", notes = "添加课程(企业内部课程)(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "saveEnterpriseCurriculum", method = RequestMethod.POST)
    public ReturnVO saveEnterpriseCurriculum(@RequestHeader String token, @RequestBody Curriculum curriculum) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        curriculum.setEnterpriseId(jsonObject.getLong("enterpriseId"));
        curriculum.setCurriculumType(1);
        curriculum.setIsDocentSend(jsonObject.getInteger("isDocent"));
        return curriculumService.saveCurriculum(jsonObject.getLong("id"), curriculum);
    }

    @ApiOperation(value = "添加课程(培训课程)(后台)", notes = "添加课程(培训课程)(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "saveDocentTrainCurriculum4trial", method = RequestMethod.POST)
    public ReturnVO saveDocentTrainCurriculum4trial(@RequestHeader String token, @RequestBody Curriculum curriculum) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        curriculum.setEnterpriseId(jsonObject.getLong("enterpriseId"));
        curriculum.setCurriculumType(3);
        curriculum.setIsDocentSend(jsonObject.getInteger("isDocent"));
        return curriculumService.saveCurriculum(jsonObject.getLong("id"), curriculum);
    }

    @ApiOperation(value = "添加课程(讲师培训课程)(后台)", notes = "添加课程(讲师培训课程)(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "saveDocentTrainCurriculum", method = RequestMethod.POST)
    public ReturnVO saveDocentTrainCurriculum(@RequestHeader String token, @RequestBody Curriculum curriculum) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        curriculum.setEnterpriseId(jsonObject.getLong("enterpriseId"));
        curriculum.setCurriculumType(2);
        curriculum.setIsDocentSend(jsonObject.getInteger("isDocent"));
        return curriculumService.saveCurriculum(jsonObject.getLong("id"), curriculum);
    }


//    @ApiOperation(value = "讲师端添加课程(后台)", notes = "讲师端添加课程(后台)", httpMethod = "POST", tags = "后台")
//    @RequestMapping(value = "saveCurriculum4docent", method = RequestMethod.POST)
//    public ReturnVO saveCurriculum4docent(@RequestHeader String token, @RequestBody Curriculum curriculum) {
//        //讲师端自动填充讲师
//        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
//        Long docentId = jsonObject.getLong("docentId");
//        curriculum.setDocentId(docentId);
//        curriculum.setIsDocentSend(1);
//        return curriculumService.saveCurriculum(jsonObject.getLong("id"), curriculum);
//    }

    @ApiOperation(value = "上架课程(后台)", notes = "上架课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "updateStatus/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO updateStatus(@RequestHeader String token, @PathVariable Long curriculumId) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        Integer isDocent = jsonObject.getInteger("isDocent");
        //讲师端上架的课程需要审核
        return curriculumService.updateStatus(curriculumId, isDocent);
    }

    @ApiOperation(value = "下架课程(后台)", notes = "下架课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "updateStatusDown/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO updateStatusDown(@RequestHeader String token, @PathVariable Long curriculumId) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return curriculumService.updateStatusDown(curriculumId);
    }

    @ApiOperation(value = "企业上架课程到平台(后台)", notes = "企业上架课程到平台(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "updatePlatformStatus", method = RequestMethod.POST)
    public ReturnVO updatePlatformStatus(@Valid @RequestBody UpdatePlatformStatusDto updatePlatformStatusDto) {
        return curriculumService.updatePlatformStatus(updatePlatformStatusDto);
    }

    @ApiOperation(value = "审核课程(后台)", notes = "审核课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "checkCurriculum", method = RequestMethod.POST)
    public ReturnVO checkCurriculum(@Valid @RequestBody CheckCurriculumDto checkCurriculumDto) {
        return curriculumService.checkCurriculum(checkCurriculumDto);
    }


    @ApiOperation(value = "修改课程(后台)", notes = "修改课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "updateCurriculum", method = RequestMethod.POST)
    public ReturnVO updateCurriculum(@RequestBody Curriculum curriculum) {
        return curriculumService.updateCurriculum(curriculum);
    }

    @ApiOperation(value = "解禁/禁用课程(后台)", notes = "解禁/禁用课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "isBanCurriculum", method = RequestMethod.POST)
    public ReturnVO isBanCurriculum(@RequestBody Curriculum curriculum) {
        return curriculumService.isBanCurriculum(curriculum);
    }


    @ApiOperation(value = "删除课程(后台)", notes = "删除课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "deleteCurriculum/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO deleteCurriculum(@PathVariable Long curriculumId) {
        return curriculumService.deleteCurriculum(curriculumId);
    }

    @ApiOperation(value = "添加或修改课程章节(后台)", notes = "添加或修改课程章节(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "saveCurriculumSection", method = RequestMethod.POST)
    public ReturnVO saveCurriculumSection(@Valid @RequestBody CurriculumSection curriculumSection) {
        return curriculumService.saveCurriculumSection(curriculumSection);
    }

    @ApiOperation(value = "根据章节id查询详情(后台)", notes = "根据章节id查询详情", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectCurriculumSectionDetail/{curriculumSectionId}", method = RequestMethod.POST)
    public ReturnVO<CurriculumSection> selectCurriculumSectionDetail(@PathVariable Long curriculumSectionId) {
        return curriculumService.selectCurriculumSectionDetail(curriculumSectionId);
    }

    @ApiOperation(value = "新增章节时根据课程id展示单元(后台)", notes = "新增章节时根据课程id展示单元(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listCurriculumUnit/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO<List<CurriculumUnit>> listCurriculumUnit(@PathVariable Long curriculumId) {
        return curriculumService.listCurriculumUnit(curriculumId);
    }

    @ApiOperation(value = "新增课程单元(后台)", notes = "新增课程单元(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "saveCurriculumUnit", method = RequestMethod.POST)
    public ReturnVO saveCurriculumUnit(@Valid @RequestBody List<CurriculumUnit> curriculumUnit) {
        return curriculumService.saveCurriculumUnit(curriculumUnit);
    }

    @ApiOperation(value = "根据id删除课程单元(后台)", notes = "根据id删除课程单元(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "deleteCurriculumUnitById/{curriculumUnitId}", method = RequestMethod.POST)
    public ReturnVO deleteCurriculumUnitById(@PathVariable Long curriculumUnitId) {
        return curriculumService.deleteCurriculumUnitById(curriculumUnitId);
    }

    @Autowired
    private IWxUserCurriculumService wxUserCurriculumService;

    @ApiOperation(value = "查看参与学习人(后台)", notes = "查看参与学习人(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listWxUserCurriculum", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<WxUserCurriculum>>> listWxUserCurriculum(@Valid @RequestBody UserCurriculumDto userCurriculumDto) {
        return wxUserCurriculumService.listWxUserCurriculum(userCurriculumDto);
    }


    @ApiOperation(value = "企业购买平台课程(后台)", notes = "企业购买平台课程(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "enterpriseBuyCurriculum/{curriculumId}", method = RequestMethod.POST)
    public ReturnVO enterpriseBuyCurriculum(@RequestHeader String token, @PathVariable Long curriculumId) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return curriculumService.enterpriseBuyCurriculum(jsonObject, curriculumId);
    }


    @ApiOperation(value = "查询该用户课程", notes = "查询该用户课程", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listWxUserCurriculumByWxUserId", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<Curriculum>>> listWxUserCurriculumByWxUserId(@RequestBody WxUserCurriculumDto wxUserCurriculumDto) {
        return wxUserCurriculumService.listWxUserCurriculumByWxUserId(wxUserCurriculumDto.getWxUserId(), wxUserCurriculumDto);
    }

    @ApiOperation(value = "职员用户的每日学习时长", notes = "职员用户的每日学习时长", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectCountStudyWxUserStatisticsVo", method = RequestMethod.POST)
    public ReturnVO<CountStudyWxUserStatisticsVo> selectCountStudyWxUserStatisticsVo(@RequestBody SelectCountStudyWxUserStatisticsDto selectCountStudyWxUserStatisticsDto) {
        return curriculumService.selectCountStudyWxUserStatisticsVo(selectCountStudyWxUserStatisticsDto);
    }

    @ApiOperation(value = "平台学习人数(概况总览)(总后台)", notes = "平台学习人数(概况总览)(总后台)", httpMethod = "POST", tags = "总后台")
    @RequestMapping(value = "countStudyPersonNum", method = RequestMethod.POST)
    public ReturnVO<CountStudyStatisticsVo> countStudyPersonNum() {
        return curriculumService.countStudyPersonNum();
    }

    @ApiOperation(value = "当前企业的学习数据(概况总览)(后台)", notes = "当前企业的学习数据(概况总览)(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectCountStudyEnterpriseStatisticsVo", method = RequestMethod.POST)
    public ReturnVO<CountStudyEnterpriseStatisticsVo> selectCountStudyEnterpriseStatisticsVo(@RequestHeader String token) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return curriculumService.selectCountStudyEnterpriseStatisticsVo(jsonObject.getLong("enterpriseId"));
    }

    @ApiOperation(value = "导出一个章节的测评题", notes = "导出一个章节的测评题", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "exportTopicSection/{curriculumSectionId}", method = RequestMethod.POST)
    public void exportTopicSection(HttpServletResponse response, @PathVariable Long curriculumSectionId) {
        curriculumService.exportTopicSection(response, curriculumSectionId);
    }

    @ApiOperation(value = "判断当前企业或平台是否有课程分类和讲师", notes = "导出一个章节的测评题", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "isHaveCategoryAndDocent", method = RequestMethod.POST)
    public ReturnVO isHaveCategoryAndDocent(@RequestHeader String token) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return curriculumService.isHaveCategoryAndDocent(jsonObject.getLong("enterpriseId"));
    }

    @ApiOperation(value = "章节测评题导入", notes = "章节测评题导入", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "importTopicSection/{curriculumSectionId}", method = RequestMethod.POST)
    public ReturnVO importTopicSection(@RequestHeader String token, @PathVariable Long curriculumSectionId, @RequestParam("file") MultipartFile file) {
        return curriculumService.importTopicSection(token, curriculumSectionId, file);
    }

    @ApiOperation(value = "查询该企业的课程英雄榜(后台)", notes = "查询该企业的课程英雄榜(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectFeignWxUserDtoByCurriculum", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<FeignWxUserDto>>> selectFeignWxUserDtoByCurriculum(HttpServletResponse response,@RequestHeader String token, @Valid @RequestBody FeignWxUserDtoByCurriculumDto feignWxUserDtoByCurriculumDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return curriculumService.selectFeignWxUserDtoByCurriculum(response,jsonObject.getLong("enterpriseId"), feignWxUserDtoByCurriculumDto);
    }

    @ApiOperation(value = "查询该企业明星讲师英雄榜(后台)", notes = "查询该企业明星讲师英雄榜(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "selectFeignWxUserDtoByDocent", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<FeignWxUserDto>>> selectFeignWxUserDtoByDocent(HttpServletResponse response,@RequestHeader String token, @Valid @RequestBody FeignWxUserDtoByCurriculumDto feignWxUserDtoByCurriculumDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return curriculumService.selectFeignWxUserDtoByDocent(response,jsonObject.getLong("enterpriseId"), feignWxUserDtoByCurriculumDto);
    }
}
